#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time: 2022/9/16 11:02
# @Author: 刘航
# @Email: xxx@gmail.com
# @File：cule_details.py

from selenium.webdriver.common.by import By
from pages.base_page import BasePage
from selenium.webdriver.support.select import Select
from time import sleep

class ViewCuleDetails(BasePage):
    add_log_locator = (By.XPATH,"/html/body/div[5]/div/div[3]/ul/li[2]/a")
    add_log_title_locator  = (By.XPATH,'//*[@id="subject"]')
    add_log_con_locator = (By.CSS_SELECTOR,".span4")
    nextstep_time_locator = (By.ID,'nextstep_time')
    nextstep_con_locator = (By.ID,"nextstep")
    save_btn_locator = (By.CSS_SELECTOR,"input.btn:nth-child(1)")
    view_log_locator = (By.XPATH, "/html/body/div[5]/div/div[1]/ul/li[3]/a")
    view_title_locator = (By.CSS_SELECTOR, '.tab-content')
    del_confirm_locator = (By.XPATH, "/html/body/div[5]/div/div[2]/div[2]/div[4]/a[2]")
    view_delete_log = (By.XPATH, "/html/body/div[5]/div/div[2]/div[1]/div[2]/div")
    view_add_log_locator =(By.CSS_SELECTOR,".alert")
    def add_cule_log(self):
        """线索详情内添加沟通日志"""
        self.driver.find_element(*self.add_log_locator).click()
    def add_cule_log_title(self,title):
        """添加沟通日志的标题"""
        self.driver.find_element(*self.add_log_title_locator).send_keys(title)
    def add_cule_log_con(self,con):
        """添加沟通日志内容"""
        self.driver.find_element(*self.add_log_con_locator).send_keys(con)
    def add_nextstep_time(self,nextstep_time):
        """添加下次联系时间"""
        self.driver.find_element(*self.nextstep_time_locator).send_keys(nextstep_time)
    def add_nextstep_con(self,nextstep_con):
        """添加下次联系内容"""
        self.driver.find_element(*self.nextstep_con_locator).send_keys(nextstep_con)
    def click_save_btn(self):
        """点击保存"""
        self.driver.find_element(*self.save_btn_locator).click()
    def view_log(self):
        """查看沟通日志"""
        self.driver.find_element(*self.view_log_locator).click()  # 切换工作台
    def view_log_title(self):
        """查看日志标题"""
        actual = self.driver.find_element(*self.view_title_locator).text  # 获取数据
        return actual
    def del_confirm(self):
        """删除沟通日志"""
        self.driver.find_element(*self.del_confirm_locator).click()
        self.driver.switch_to.alert.accept()
        sleep(1)
    def view_delete_status(self):
        """获取删除后的数据"""
        actual = self.driver.find_element(*self.view_delete_log).text  #
        return actual

    def view_add_log(self):
        """查看添加状态"""
        actual = self.driver.find_element(*self.view_add_log_locator).text  # 获取数据
        return actual
    def add_log_func(self,title,con,nextstep_time,nextstep_con):
        """添加沟通日志"""
        self.add_cule_log()
        self.add_cule_log_title(title)
        self.add_cule_log_con(con)
        self.add_nextstep_time(nextstep_time)
        self.add_nextstep_con(nextstep_con)
        self.click_save_btn()



